<template>
  <div class="wrapper">
    <v-header></v-header>
    <v-sidebar></v-sidebar>
    <div class="content-box" :class="{ 'content-collapse': sidebar.collapse }">
      <v-tags></v-tags>
      <div class="content" id="target">
        <router-view v-slot="{ Component }">
          <transition name="fade-transform" mode="out-in">
            <keep-alive :include="tags.nameList">
              <component :is="Component" />
            </keep-alive>
          </transition>
        </router-view>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useSidebarStore } from '@/store/sidebar';
import { useTagsStore } from '@/store/tags';
import VHeader from '@/components/Header.vue';
import VSidebar from '@/components/Sidebar.vue';
import VTags from '@/components/Tags.vue';
const sidebar = useSidebarStore();
const tags = useTagsStore();
</script>
<style scoped>
.content {
  overflow-y: auto;
}

.content-box {
  background-color: #f8f8f8;
}

.fade-transform-leave-active {
  animation: fade-transform-in 0.5s;
}

.fade-transform-enter-active {
  animation: fade-transform-out 0.8s;
}

@keyframes fade-transform-in {
  from {
    opacity: 1;
  }

  to {
    transform: translateX(30px);
    opacity: 0;
  }
}

@keyframes fade-transform-out {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 0.8;
  }
}
</style>